HA$PBExportHeader$w_distri_mplantillaceco.srw
forward
global type w_distri_mplantillaceco from w_help_main
end type
type cb_1 from commandbutton within w_distri_mplantillaceco
end type
type cb_2 from commandbutton within w_distri_mplantillaceco
end type
end forward

global type w_distri_mplantillaceco from w_help_main
integer width = 2226
integer height = 1008
cb_1 cb_1
cb_2 cb_2
end type
global w_distri_mplantillaceco w_distri_mplantillaceco

type variables
string is_indice,is_plantilla,is_plnc,is_ejercicio

end variables
on w_distri_mplantillaceco.create
int iCurrent
call super::create
this.cb_1=create cb_1
this.cb_2=create cb_2
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_1
this.Control[iCurrent+2]=this.cb_2
end on

on w_distri_mplantillaceco.destroy
call super::destroy
destroy(this.cb_1)
destroy(this.cb_2)
end on

event open;call super::open;string ls_cuenta
long ll_plnc
is_plantilla =string( istr_parm.long_parm[1])
ll_plnc = istr_parm.long_parm[3]
is_indice   =string( istr_parm.long_parm[2])
is_plnc   =string( istr_parm.long_parm[3])
is_ejercicio  =  istr_parm.string_parm[1]
//SELECT tCuenta into :ls_cuenta from mplnc where idplnc = :ll_plnc;

dw_1.GetChild("idceco", dwc);dwc.reset()
dwc.settransobject(sqlca) ; dwc.retrieve()

//dw_1.GetChild("idplnc", dwc);dwc.reset(); dwc.settransobject(sqlca) ; dwc.retrieve()
//dwc.setfilter('left(tCuenta,2) = "'+ls_cuenta+'"');dwc.filter()

istr_parm.dw_parm[1].setfilter('string(idplantilla)= string("'+is_plantilla+'") and string(idindice)= string("'+is_indice+'")  ')
istr_parm.dw_parm[1].filter()
istr_parm.dw_parm[1].RowsCopy(istr_parm.dw_parm[1].GetRow(), istr_parm.dw_parm[1].RowCount(), Primary!, dw_1 , 1, Primary!)

if dw_1.rowcount() > 0  then istr_parm.char_parm[1]='1'

end event

type cb_cancelar from w_help_main`cb_cancelar within w_distri_mplantillaceco
integer width = 393
end type

type cb_aceptar from w_help_main`cb_aceptar within w_distri_mplantillaceco
integer width = 393
end type

event cb_aceptar::clicked;if dw_1.accepttext( ) =  - 1  then return 0
If f_findrequired(dw_1) = -1 Then Return 0

if dw_1.event ue_validar() = - 1  then return  0

istr_parm.char_parm[1]='1'


if dw_1.rowcount() = 0 then
	istr_parm.char_parm[1]='0'
	// elimina todo el contenido del dw
	DO while istr_parm.dw_parm[1].rowcount() > 0 
		istr_parm.dw_parm[1].deleterow(0)
	Loop 
Else
	if f_msj('$$HEX1$$bf00$$ENDHEX$$Desea Guardar lo cambios?' , 2 ) = 2 then return 
	istr_parm.char_parm[1]='1'
	// elimina todo el contenido del dw
	DO while istr_parm.dw_parm[1].rowcount() > 0 
		istr_parm.dw_parm[1].deleterow(0)
	Loop 

	// Hace una copia al dw 
	dw_1.scrolltorow(1)
	dw_1.RowsCopy(dw_1.GetRow(), dw_1.RowCount(), Primary!, istr_parm.dw_parm[1] , 1 , Primary!)
End if
cb_cancelar.event post clicked()
end event

type dw_1 from w_help_main`dw_1 within w_distri_mplantillaceco
integer x = 18
integer y = 12
integer width = 2153
string dataobject = "d_mplantillaceco_tabular"
end type

event dw_1::ue_validar;call super::ue_validar;if dw_1.rowcount() > 0  then
	 if dw_1.object.cc_total[1] <> 100 then 
		f_msj('El total % debe ser igual a 100',4); return -1
	 end if
end if

return 1

end event

type cb_1 from commandbutton within w_distri_mplantillaceco
integer x = 923
integer y = 804
integer width = 393
integer height = 112
integer taborder = 40
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "A&gregar"
end type

event clicked;dw_1.insertrow(0)
dw_1.object.idplantilla   [dw_1.rowcount()]   = istr_parm.long_parm[1] 
dw_1.object.idindice[dw_1.rowcount()]   = 	istr_parm.long_parm[2] 
dw_1.object.idplnc[dw_1.rowcount()]   = 	istr_parm.long_parm[3] 
dw_1.object.idejercicio[dw_1.rowcount()]   = istr_parm.string_parm[1] 



end event

type cb_2 from commandbutton within w_distri_mplantillaceco
integer x = 1339
integer y = 804
integer width = 393
integer height = 112
integer taborder = 50
boolean bringtotop = true
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Arial"
string text = "&Quitar"
end type

event clicked;integer li_fila
// Verifica si esta por tipo de operacion 
if dw_1.rowcount() = 0 then return
if dw_1.getrow() = 0 then return

dw_1.deleterow(0)

//for li_fila = 1 to dw_1.rowcount()
//	dw_1.object.indice[li_fila] =li_fila
//next
//
//
end event

